package com.tanhua.server.controller;

import com.tanhua.domain.db.Settings;
import com.tanhua.domain.db.UserInfo;
import com.tanhua.server.service.SettingsService;
import com.tanhua.server.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
@RequestMapping("/users")
public class SettingController {

//    1、请求方式  get
//    2、url地址 /users/settings
//    3、请求参数  application/json   有请求头 Authorization
//    4、返回结果  settingsVo

    @Autowired
    private SettingsService settingsService;

    @GetMapping(value = "/settings",name = "获取当前登录人的通用设置")
    public ResponseEntity querySettings(){

        return settingsService.querySettings();
    }

    @PostMapping(value = "/questions",name = "保存当前登录人设置的陌生人问题")
//    {"content":"大海还是高山"}
    public ResponseEntity saveQuestions(@RequestBody Map map){
        String content = (String) map.get("content");
        return settingsService.saveQuestions(content);
    }

    @PostMapping(value = "/notifications/setting",name = "保存当前登录人的通知设置")
    public ResponseEntity saveNotifications(@RequestBody Settings settings){
        return settingsService.saveNotifications(settings);
    }

    @GetMapping(value = "/blacklist",name = "分页查询黑名单数据")
    public ResponseEntity queryBlacklist(@RequestParam(defaultValue = "1") Integer page,
                                         @RequestParam(defaultValue = "10")Integer pagesize){
        return settingsService.queryBlacklist(page,pagesize);
    }

    @DeleteMapping(value = "/blacklist/{uid}",name = "取消黑名单数据")
    public ResponseEntity deleteBlacklist(@PathVariable("uid") Long blackUserId){
        return settingsService.deleteBlacklist(blackUserId);
    }

}
